//
//  HomeViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HomeViewController.h"
#import "HomeNavTitView.h"
#import "HomeViewModel.h"
#import "GoodsSearchViewController.h"
#import "AdressChangeViewController.h"
#import "HighQualityStoreViewController.h"
#import "NeedPurchaseViewController.h"
#import "SuperMarketViewController.h"
#import "IndustryInformationViewController.h"
#import "StellCaiculatorViewController.h"
#import "OrderAllListViewController.h"
#import "NeedHallViewController.h"
#import "HugeAmountsBuyersViewController.h"
#import "LookForGoodsViewController.h"
#import "QcodeInformationViewController.h"
#import "CodeScanTools.h"

@interface HomeViewController ()<HomeModelDelegate>
@property (nonatomic,strong)HomeViewModel * h_viewModel;

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.titleView  = [self createNavView];
    [self addNavigationItemWithTitles:@[@"北京"] isLeft:YES target:self action:@selector(back) tags:@[@33] theButTitColor:[UIColor colorWithHexString:@"#333333"] titFont:SYSTEMFONT(15)];
    if (self.accountType == AccountType_FreeManagers) {
        [self addNavigationItemWithImageNames:@[@"home_Shape"] isLeft:NO target:self action:@selector(messgaeAction) tags:@[@11]];
    }else{
        [self addNavigationItemWithImageNames:@[@"home_saosao"] isLeft:NO target:self action:@selector(saoCodeAction) tags:@[@33]];
    }
    self.h_viewModel = [[HomeViewModel alloc] initWithViewToViewModel:self.view];
    self.h_viewModel.delegate = self;
}

-(void)saoCodeAction{
//    QcodeInformationViewController * q_loginVC = [QcodeInformationViewController new];
//    [self.navigationController pushViewController:q_loginVC animated:YES];
    [CodeScanTools permitCameraWithTarget:self PushScanView:[QcodeInformationViewController new]];
}

-(void)messgaeAction{
    DLog(@"消息");
}

-(UIView *)createNavView {
    HomeNavTitView * navView = [[HomeNavTitView alloc] initWithFrame:CGRectMake(0, 0, kWidthProportion_In_iPhoneTriploid(250), kHeightProportion_In_iPhoneTriploid(30))];
    navView.Block_SearchAction = ^{
        GoodsSearchViewController * goodsSearchVC = [GoodsSearchViewController new];
        [self.navigationController pushViewController:goodsSearchVC animated:YES];
        //包装一个导航栏控制器
//        GLGWBaesNavigationController * nav = [[GLGWBaesNavigationController alloc]   initWithRootViewController:goodsSearchVC];
//        [self presentViewController:nav animated:NO completion:nil];
    };
    [[navView.saoMaBut rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        QcodeInformationViewController * q_loginVC = [QcodeInformationViewController new];
        [self.navigationController pushViewController:q_loginVC animated:YES];
    }];
    return navView;
}

-(void)back{
    AdressChangeViewController * adressVc = [AdressChangeViewController new];
    [self.navigationController pushViewController:adressVc animated:YES];
}

#pragma mark --- HomeModelDelegate;
-(void)homeEightButAction:(GLGWButton *)e_but{
    switch (e_but.tag) {
        case 120:{
            if (self.accountType == AccountType_Ordinary) {//钢材超市
                SuperMarketViewController * superVC = [SuperMarketViewController new];
                [self.navigationController pushViewController:superVC animated:YES];
            }else{//求购大厅
                NeedHallViewController * needHallVC = [NeedHallViewController new];
                [self.navigationController pushViewController:needHallVC animated:YES];
            }
            
        }
            break;
        case 121:{
            if (self.accountType == AccountType_Ordinary) {//y优质店铺
                HighQualityStoreViewController * hightVc = [HighQualityStoreViewController new];
                [self.navigationController pushViewController:hightVc animated:YES];
            }else{//海量买家
                HugeAmountsBuyersViewController * hugeAmountsVc = [HugeAmountsBuyersViewController new];
                [self.navigationController pushViewController:hugeAmountsVc animated:YES];
            }
            
        }
            break;
        case 122:{
            if (self.accountType == AccountType_Ordinary) {//我的求购
                NeedPurchaseViewController * needPVC = [NeedPurchaseViewController new];
                [self.navigationController pushViewController:needPVC animated:YES];
            }else{//找货神器
                LookForGoodsViewController * lookForGoodsVc = [LookForGoodsViewController new];
                [self.navigationController pushViewController:lookForGoodsVc animated:YES];
            }
        }
            break;
        case 123:{
            if (self.accountType == AccountType_Ordinary) {//行业资讯
                IndustryInformationViewController * industryVC = [IndustryInformationViewController new];
                [self.navigationController pushViewController:industryVC animated:YES];
            }else{//优质店铺
                HighQualityStoreViewController * hightVc = [HighQualityStoreViewController new];
                [self.navigationController pushViewController:hightVc animated:YES];
            }
            
        }
            break;
//自由经理人
        case 124:{//钢材资源库
            SuperMarketViewController * stellMarkVC = [SuperMarketViewController new];
            [self.navigationController pushViewController:stellMarkVC animated:YES];
        }
            break;
        case 125:{//行情资讯
            IndustryInformationViewController * industryVC = [IndustryInformationViewController new];
            [self.navigationController pushViewController:industryVC animated:YES];
        }
            break;
        case 126:{//我的订单
            OrderAllListViewController * orderVC = [OrderAllListViewController new];
            [self.navigationController pushViewController:orderVC animated:YES];
        }
            break;
        case 127:{//钢铁计算器
            StellCaiculatorViewController * stellCaiVc = [StellCaiculatorViewController new];
            [self.navigationController pushViewController:stellCaiVc animated:YES];
        }
            break;
            
        default:
            break;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
